
from math import sqrt

primes = []
def prime_iter():
    yield 2
    i = 3
    while True:
        is_prime = True
        max_factor = sqrt(i)
        for p in primes:
            if p > max_factor:
                break
            if i % p == 0:
                is_prime = False
                break
        if is_prime:
            yield i
            primes.append(i)
        i += 2

def test_tp(p):
    sp = str(p)
    l = len(sp)
    if l == 1:
        return False
    for i in range(1, l):
        tl = int(sp[i:])
        if tl != 2 and tl not in primes:
            return False
        tr = int(sp[:-i])
        if tr != 2 and tr not in primes:
            return False
    return True

count = 0
sum = 0
for p in prime_iter():
    if not test_tp(p):
        continue
    print p
    count += 1
    sum += p
    if count == 11:
        break
print 'sum:', sum